package com.example.lotterysystem.common.exception;

import com.example.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
//不写可能会出现问题
public class ControllerException extends RuntimeException{
    //异常码
    private Integer code;

    //异常消息
    private String message;

    //无参构造(为了序列化)
    private ControllerException(){

    }

    //有参构造
    public ControllerException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public ControllerException(ErrorCode errorCode){
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }
}
